﻿@model Webcar.Entitys.CarCost
@{ Layout = "~/Views/Shared/_leftPanelLayout.cshtml";}
@section LeftTree
{
     
    @{
        Html.RenderPartial("DeptTreePartialView", new Webcar.Models.DeptTreeMode { Action = "CostList", Controller = "Car", ShowChild = false });
     }
}
@using (Html.BeginForm("CostSave", "Car", Html.ViewContext.RouteData.Values,FormMethod.Post))
{
    @Html.AntiForgeryToken()
    @Html.HiddenFor(a => a.carno)
    <div id="edit-car" style="width:700px;margin:5px 5px 5px 5px">
        <table class="edit-table">
            <tr>
                <td style="width: 80px; text-align: right;">*所属单位：</td>
                <td>@Html.DropDownListFor(a => a.dept_Code, WebcarDataHelper.UserSuperDeptList, new { @style = "width: 100%;", @onchange = "changeDept();" })</td>
                <td style="width: 80px; text-align: right">*车辆牌照：</td>
                <td>
                    @*@Html.DropDownListFor(a => a.carno, WebcarDataHelper.GetCarByDeptList(Model.dept_Code), new { @style = "width: 100%;", @onchange = "retriveFuelMile();" })*@
                    @Html.TextBox("RECORD_NO",(string)@ViewBag.RecordNo)
                </td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">*月份：</td>
                <td>@Html.TextBoxFor(a => a.ny)</td>
                <td style="width: 80px; text-align: right">住宿费：</td>
                <td>@Html.TextBoxFor(a => a.zs_fee)</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">差旅费：</td>
                <td>@Html.TextBoxFor(a => a.cl_fee, new { @style = "width: 100%;" })</td>
                <td style="width: 80px; text-align: right;">路桥费：</td>
                <td>@Html.TextBoxFor(a => a.lq_fee, new { @style = "width: 100%;" })</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">洗车费：</td>
                <td>@Html.TextBoxFor(a => a.xc_fee)</td>
                <td style="width: 80px; text-align: right">停车费：</td>
                <td>@Html.TextBoxFor(a => a.tc_fee, new { @style = "width: 100%;" })</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">年审费：</td>
                <td>@Html.TextBoxFor(a => a.ns_fee)</td>
                <td style="width: 80px; text-align: right">路桥年票：</td>
                <td>@Html.TextBoxFor(a => a.lq_year, new { @style = "width: 100%;" })</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">路桥月票：</td>
                <td>@Html.TextBoxFor(a => a.lq_month)</td>
                <td style="width: 80px; text-align: right">养路费：</td>
                <td>@Html.TextBoxFor(a => a.road_fee, new { @style = "width: 100%;" })</td>
            </tr>
            
            <tr>
                <td style="width: 80px; text-align: right;">本月耗油量：</td>
                <td>@Html.TextBoxFor(a => a.oil_nums, new {@onblur="calc_fuel_money();" })</td>
                <td style="width: 80px; text-align: right">油料单价：</td>
                <td>@Html.TextBoxFor(a => a.oil_price, new {@onblur="calc_fuel_money();" })</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right">
                    油料费：
                </td>
                <td>@Html.TextBoxFor(a => a.oil_fee)</td>
                <td style="width: 80px; text-align: right;">其他费用：</td>
                <td>@Html.TextBoxFor(a => a.other_fee)</td>
                
            </tr>
        </table>


        <br />
        <div class="validation-errors">@ViewBag.ErrorMessage</div>

    </div>
    <table style="width:700px">
        <tr>
            <td style="width:650px"></td>
            <td>
                @Html.DevExpress().Button(settings =>
        {
            settings.Name = "Button1";
            settings.Text = CurrentUser.CheckPermission(PermissionManager.编辑单车成本) ? "保存" : "无权限";
            settings.Enabled = CurrentUser.CheckPermission(PermissionManager.编辑单车成本);
            settings.UseSubmitBehavior = true;
            settings.Width = 70;
            settings.ControlStyle.CssClass = "button1";
        }).GetHtml()
                

            </td>
            <td>
                @Html.DevExpress().Button(settings =>
                {
                    settings.ControlStyle.CssClass = "button2";
                    settings.Name = "Button2";
                    settings.Text = "取消";
                    settings.Width = 70;
                    settings.ClientSideEvents.Click = "function(s, e){ location.href='" + @Url.Action("CostList", "Car") + "' }";
                }).GetHtml()
            </td>
        </tr>

    </table>
    
 
}

   <script type="text/javascript">
    $(function () {
        changeDept();
        $("#RECORD_NO").change(function () {
            $("#carno").val("");
        });
    });
    function changeDept() {
        setCarAutoComplete("RECORD_NO", $("#dept_Code").val(),
            '@Url.Action("GetAutoCompleteCar","Common")',
            function (event, ui) {
                $("#carno").val(ui.item.key);
                retriveFuelMile();
            }
        );
    };
    function retriveFuelMile() {
        var select = $('#carno');
        var action = '@Url.Action("RetrieveCarOil","Common")';
        var selectCar = select.val();
        var ny = $('#ny').val();
        $.get(action, { car_no: selectCar, month: ny }, function (data) {
            $('#oil_nums').val(data);
            calc_fuel_money();
        });
    };
    function calc_fuel_money() {
        var price = $('#oil_price').val();
        var number = $('#oil_nums').val();
        $('#oil_fee').val((Math.round(price * number * 100) / 100));
    };
</script>    